﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.IO;

namespace DL_Monster_Mash_WCF_Streamed
{
    // NOTE: If you change the interface name "IService1" here, you must also update the reference to "IService1" in Web.config.
    [ServiceContract]
    public interface IMonsterMashStreamingService
    {

        [OperationContract]
        string GetData(int value);

        [OperationContract]
        CompositeType GetDataUsingDataContract(CompositeType composite);

        // TODO: Add your service operations here

        // EDN Monster Mash Code:

        //[OperationContract]
        //StreamedDocumentumObject GetDocumentumObject(String sQualifier);

        [OperationContract]
        String[] GetListOfContentObjects(String sQualifier);

        [OperationContract]
        Byte[] GetDocumentumContent(String objectID);

        [OperationContract]
        DocumentumObject[] GetListOfRepositoryObjects(String sQualifier);



    }


    // Use a data contract as illustrated in the sample below to add composite types to service operations.
    [DataContract]
    public class CompositeType
    {
        bool boolValue = true;
        string stringValue = "Hello ";

        [DataMember]
        public bool BoolValue
        {
            get { return boolValue; }
            set { boolValue = value; }
        }

        [DataMember]
        public string StringValue
        {
            get { return stringValue; }
            set { stringValue = value; }
        }
    }


    //EDN Monster Mash Code
    [DataContract]
    public class DocumentumObject
    {
        private String r_object_id;
        private String object_name;

        [DataMember]
        public String ID
        {
            get { return r_object_id; }
            set { r_object_id = value; }
        }

        [DataMember]
        public String Name
        {
            get { return object_name; }
            set { object_name = value; }
        }
    }

    [MessageContract]
    public class StreamedDocumentumObject
    {
        private String m_ID;
        private Stream m_ObjectContent;

        [MessageHeader]
        public String r_object_id
        {
            get { return m_ID; }
            set { m_ID = value; }
        }

        [MessageBodyMember]
        public Stream Content
        {
            get { return m_ObjectContent; }
            set { m_ObjectContent = value; }
        }

        public StreamedDocumentumObject(String objId, Byte[] bytesOfContent)
        {
            m_ID = objId;

            if (null == bytesOfContent || bytesOfContent.Count() == 0)
            {
                return;
            }

            m_ObjectContent = new MemoryStream(bytesOfContent);
            
        }


    }

}
